<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>

    <!-- Bootstrap -->
    <link href="<?=base_url();?>/public/resource/default/vendor/bootstrap/css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link href="<?=base_url();?>/public/resource/default/css/style.css" rel="stylesheet" >

</head>
<body>

<div class="container-fluid wp-content">

    <div class="wp-content-mbx">
        <a><span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span></a>
        <div>
            <span class="mainhead">编辑分类目录</span>
            <span class="subhead">这里是其他的说明性文字</span>
        </div>
    </div>

    <div>

        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">编辑分类目录</a></li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="home">
                <!-- 操作提示框 -->
                <div class="alert alert-success" role="alert">
                    <p>重要提示</p>
                    <a href="#" class="alert-link">...</a>
                    Heads up! This alert needs your attention, but it's not super important.
                </div>

                <div class="wp-panel panel-default">
                    <div class="wp-panel-heading">
                        <span class="wp-h-mainhead">修改分类目录</span>
                    </div>
                    <div class="wp-panel-body">
                        <form id="edit-category-fm">
                            <input type="hidden" name="id" value="<?=$category->ID?>" >
                            <div class="form-group">
                                <label for="iptCategoryName">分类名称</label>
                                <input class="form-control" id="iptCategoryName" type="text" name="category_name" value="<?=$category->category_name?>" placeholder="分类名称">
                            </div>
                            <div class="form-group">
                                <label for="">父级分类</label>
                                <select class="form-control" name="parent">
                                    <option value="0" <?php if ( 0 === intval($category->parent)) : echo 'selected'; endif; ?> >作为顶级分类</option>
                                    <?php foreach ($category_array as $item): ?>
                                        <option value="<?=$item->ID?>" <?php if ( intval($item->ID) === intval($category->parent)) : echo 'selected'; endif; ?> ><?=$item->category_name?></option>
                                    <?php endforeach;?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="iptAlias">分类别名</label>
                                <input class="form-control" id="iptAlias" type="text" name="category_alias" value="<?=$category->category_alias?>" placeholder="分类别名">
                                <p class="help-block">“别名”是在URL中使用的别称，它可以令URL更美观。通常使用小写，只能包含字母，数字.</p>
                            </div>

                            <button type="button" class="btn btn-default" onclick="fun_edit_category();">提交</button>
                        </form>
                        <div>

                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<?=base_url();?>/public/resource/default/vendor/bootstrap/js/bootstrap.min.js"></script>

<script src="<?=base_url();?>/public/resource/default/js/init.js"></script>


<script>

    function fun_edit_category() {
        $.ajax({
            url:       '<?=site_url('category/edit_post')?>',
            type:      'post',
            dataType:  'json',
            data:      $('#edit-category-fm').serialize(),
            async:     false,
            success: function(response){

                alert(response.resultMsg);

                if (response.resultCode == CHttp.getConstant('HTTP_STATUS_SUCCESS'))
                {
                    location.reload();
                }
            },
            error: function(request){
                alert('Error');
            }
        })
    }


</script>

</body>
</html>